package datastructure.sort.bean;


import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * Created by tanlee on 2016/3/17.
 */
public class MyDataManager {

    private static Random random = new Random();

    /**
     * 随机生成一个list
     * @param size
     * @return
     */

    public static List<MySortData> getRandomDataList(int size){
        List<MySortData> mySortData = new ArrayList<MySortData>();
        for(int i=0;i<size;i++){
            MySortData data = new MySortData(random.nextInt(size));
            mySortData.add(data);
        }
        return  mySortData;
    }

    /**
     * 随机生成一个无序的数组
     * @param size
     * @return
     */
    public static MySortData[] getRandomDataArray(int size){
        MySortData[] mySortDataArray = new MySortData[size];
        for(int i=0;i<size;i++){
            mySortDataArray[i] = new MySortData(random.nextInt(size));
        }
        return mySortDataArray;
    }

    public static void showArray(MySortData[] array){
        String result = "";
        for (int i=0;i<array.length;i++){
            result += array[i].num + " ";
        }
        System.out.println(result + "\n");
    }
}
